import {
  q as n,
  p as N,
  ap as T,
  X as b,
  f as M,
  H as R,
  av as B,
  aw as O,
  k as t,
  m as s,
  l as a,
  az as H,
  as as c,
  aG as P,
  at as g,
  b3 as j,
  b4 as q
} from "./index-b50e6ef9.js";
function X(F) {
  const h = n([]),
    u = n(!0);
  n({}), N();
  const m = n(1),
    y = n({}),
    x = n(10),
    E = T("reload"),
    v = b({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    W = b({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    A = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "user_id", minWidth: 50 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      {
        label: "等级",
        prop: "user_vip",
        minWidth: 80,
        formatter: ({ user_vip: e }) => {
          if (e == 1)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("VIP会员")] }
            );
          if (e == 3)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("普通会员")] }
            );
        }
      },
      {
        label: "身份",
        prop: "user_place",
        minWidth: 80,
        formatter: ({ user_place: e }) =>
          t("span", null, [
            e == 1
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("一星合伙人")] }
                )
              : e == 2
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("二星合伙人")] }
                )
              : e == 3
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("三星合伙人")] }
                )
              : e == 4
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("四星合伙人")] }
                )
              : e == 5
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("五星合伙人")] }
                )
              : e == 6
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("一星联创")] }
                )
              : e == 7
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("二星联创")] }
                )
              : e == 8
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("三星联创")] }
                )
              : e == 9
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("四星联创")] }
                )
              : e == 10
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("一星董事")] }
                )
              : e == 11
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("二星董事")] }
                )
              : e == 12
              ? t(
                  a("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [s("三星董事")] }
                )
              : t(
                  a("el-tag"),
                  { class: "mx-1", type: "info", effect: "light" },
                  { default: () => [s("暂无")] }
                )
          ])
      },
      { label: "档位", prop: "user_position", minWidth: 150 },
      { label: "点位", prop: "user_divvy", minWidth: 150 },
      {
        label: "备注",
        prop: "month_vip",
        minWidth: 80,
        formatter: ({ month_vip: e, month_indent: l }) => {
          if (e == 1 && l == 1)
            return t("div", null, [
              " ",
              t(
                a("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [s("推荐会员")] }
              ),
              t(
                a("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [s("复购产品")] }
              )
            ]);
          if (l == 1 && l == 0)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("推荐会员")] }
            );
          if (l == 0 && l == 1)
            return t(
              a("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [s("复购产品")] }
            );
          if (l == 0 && l == 0) return "";
        }
      }
    ],
    C = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "user_id", minWidth: 50 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      { label: "等级", prop: "user_vip", minWidth: 80 },
      { label: "身份", prop: "user_place", minWidth: 80 },
      { label: "档位", prop: "user_position", minWidth: 150 },
      { label: "点位", prop: "user_divvy", minWidth: 150 },
      { label: "推荐会员", prop: "month_vip", minWidth: 80 },
      { label: "复购产品", prop: "month_indent", minWidth: 80 },
      { label: "1", prop: "0", minWidth: 80 }
    ],
    D = M(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function w(e) {
    H(e);
  }
  async function I(e) {
    const l = { role_id: e.role_id },
      f = JSON.stringify(l),
      d = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(f)) },
      i = await P(d);
    i.code == 200
      ? (g("删除成功", { type: "success" }), E())
      : g(i.msg, { type: "error" });
  }
  function S() {}
  function J(e) {
    (x.value = e), r(void 0, e);
  }
  function V(e) {
    (m.value = e), r(e, void 0);
  }
  function k(e) {}
  function U(e) {
    (W.text = `正在加载第${e}页...`),
      (u.value = !0),
      B(600).then(() => {
        u.value = !1;
      });
  }
  async function z(e) {
    u.value = !0;
    const l = { money: e.money },
      f = JSON.stringify(l),
      d = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(f)) },
      { code: i } = await j(d);
    i == 200 &&
      (r(),
      (e.money = ""),
      setTimeout(() => {
        u.value = !1;
      }, 500));
  }
  async function r(e = m.value, l = x.value) {
    const p = JSON.stringify({ page: e, pagesize: l }),
      i = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(p)) },
      o = await q(i);
    o.code === 200
      ? ((y.value = o.data),
        (h.value = o.data.list.data),
        (v.total = o.data.list.total),
        setTimeout(() => {
          u.value = !1;
        }, 500))
      : g(o.msg, { type: "error" });
  }
  const L = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    R(() => {
      B().then(() => {
        const { setWatermark: e } = O(F.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        r();
    }),
    {
      loading: u,
      columns: A,
      dataList: h,
      pagination: v,
      buttonClass: D,
      formValue: y,
      columnsTable: C,
      onSearch: z,
      resetForm: L,
      handleaddUser: S,
      handleUpdate: w,
      handleDelete: I,
      handleSizeChange: J,
      handleCurrentChange: V,
      handleSelectionChange: k,
      onCurrentChange: U
    }
  );
}
export { X as useRole };
